package com.wish.group05.shoufang.controller;

import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.wish.group05.base.entity.MOwner;
import com.wish.group05.base.service.IMOwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wish.group05.common.log.annotation.Log;
import com.wish.group05.common.log.enums.BusinessType;
import com.wish.group05.common.security.annotation.PreAuthorize;
import com.wish.group05.common.core.web.controller.BaseController;
import com.wish.group05.common.core.web.domain.AjaxResult;
import com.wish.group05.common.core.utils.poi.ExcelUtil;
import com.wish.group05.common.core.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author wish
 * @date 2022-05-27
 */
@RestController
@RequestMapping("/owner")
public class TMOwnerController extends BaseController
{
    @Autowired
    private IMOwnerService imOwnerService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize(hasPermi = "shoufang:owner:list1")
    @GetMapping("/list")
    public TableDataInfo list(MOwner tMOwner)
    {
        startPage();

        List<MOwner> list = imOwnerService.list();
        return getDataTable(list);
    }

     /*获取【请填写功能名称】详细信息*/

    @PreAuthorize(hasPermi = "shoufang:owner:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        MOwner mOwner = imOwnerService.getById(id);
        return AjaxResult.success(mOwner);
    }
     /*新增【请填写功能名称】*/
    @PreAuthorize(hasPermi = "shoufang:owner:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MOwner tMOwner)
    {
        boolean save = imOwnerService.save(tMOwner);
        return toAjax(save==true?1:0);
    }
    //修改
    @PreAuthorize(hasPermi = "system:owner:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MOwner tMOwner)
    {
        boolean save = imOwnerService.saveOrUpdate(tMOwner);
        return toAjax(save==true?1:0);
    }
     /*删除【请填写功能名称】*/

    @PreAuthorize(hasPermi = "shoufang:owner:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        boolean b = imOwnerService.removeByIds(Arrays.asList(ids));
        return toAjax(b==true?1:0);
    }
}
